package com.ymkj.testdemo.RSA;

import org.springframework.util.StringUtils;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Map;
import java.util.TreeMap;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;


public class RSAEncrypt {
	/**
	 * 字节数据转字符串专用集合
	 */
	private static final char[] HEX_CHAR = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
			'f' };

	/**
	 * 随机生成密钥对
	 */
	public static void genKeyPair(String filePath) {
		// KeyPairGenerator类用于生成公钥和私钥对，基于RSA算法生成对象
		KeyPairGenerator keyPairGen = null;
		try {
			keyPairGen = KeyPairGenerator.getInstance("RSA");
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// 初始化密钥对生成器，密钥大小为96-1024位
		keyPairGen.initialize(1024, new SecureRandom());
		// 生成一个密钥对，保存在keyPair中
		KeyPair keyPair = keyPairGen.generateKeyPair();
		// 得到私钥
		RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
		// 得到公钥
		RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
		try {
			// 得到公钥字符串
			String publicKeyString = Base64.encode(publicKey.getEncoded());
			// 得到私钥字符串
			String privateKeyString = Base64.encode(privateKey.getEncoded());

			checkOrCreateFile(filePath + "/publicKey.keystore");
			checkOrCreateFile(filePath + "/privateKey.keystore");
			// 将密钥对写入到文件
			FileWriter pubfw = new FileWriter(filePath + "/publicKey.keystore");
			FileWriter prifw = new FileWriter(filePath + "/privateKey.keystore");
			BufferedWriter pubbw = new BufferedWriter(pubfw);
			BufferedWriter pribw = new BufferedWriter(prifw);
			pubbw.write(publicKeyString);
			pribw.write(privateKeyString);
			pubbw.flush();
			pubbw.close();
			pubfw.close();
			pribw.flush();
			pribw.close();
			prifw.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static void checkOrCreateFile(String fileName) throws IOException {
		File file = new File(fileName);
		if (!file.getParentFile().exists()) {
			file.getParentFile().mkdirs();
		}
		if (!file.exists()) {
			file.createNewFile();
		}
	}

	/**
	 * 从文件中输入流中加载公钥
	 *
	 * @param path
	 *            公钥输入流
	 * @throws Exception
	 *             加载公钥时产生的异常
	 */
	public static String loadPublicKeyByFile(String path) throws Exception {
		try {
			BufferedReader br = new BufferedReader(new FileReader(path + "/publicKey.keystore"));
			String readLine = null;
			StringBuilder sb = new StringBuilder();
			while ((readLine = br.readLine()) != null) {
				sb.append(readLine);
			}
			br.close();
			return sb.toString();
		} catch (IOException e) {
			throw new Exception("公钥数据流读取错误");
		} catch (NullPointerException e) {
			throw new Exception("公钥输入流为空");
		}
	}

	/**
	 * 从字符串中加载公钥
	 *
	 * @param publicKeyStr
	 *            公钥数据字符串
	 * @throws Exception
	 *             加载公钥时产生的异常
	 */
	public static RSAPublicKey loadPublicKeyByStr(String publicKeyStr) throws Exception {
		try {
			byte[] buffer = Base64.decode(publicKeyStr);
			KeyFactory keyFactory = KeyFactory.getInstance("RSA");
			X509EncodedKeySpec keySpec = new X509EncodedKeySpec(buffer);
			return (RSAPublicKey) keyFactory.generatePublic(keySpec);
		} catch (NoSuchAlgorithmException e) {
			throw new Exception("无此算法");
		} catch (InvalidKeySpecException e) {
			throw new Exception("公钥非法");
		} catch (NullPointerException e) {
			throw new Exception("公钥数据为空");
		}
	}

	/**
	 * 从文件中加载私钥
	 *
	 * @param path
	 *            私钥文件名
	 * @return 是否成功
	 * @throws Exception
	 */
	public static String loadPrivateKeyByFile(String path) throws Exception {
		try {
			BufferedReader br = new BufferedReader(new FileReader(path + "/privateKey.keystore"));
			String readLine = null;
			StringBuilder sb = new StringBuilder();
			while ((readLine = br.readLine()) != null) {
				sb.append(readLine);
			}
			br.close();
			return sb.toString();
		} catch (IOException e) {
			throw new Exception("私钥数据读取错误");
		} catch (NullPointerException e) {
			throw new Exception("私钥输入流为空");
		}
	}

	public static RSAPrivateKey loadPrivateKeyByStr(String privateKeyStr) throws Exception {
		try {
			byte[] buffer = Base64.decode(privateKeyStr);
			PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(buffer);
			KeyFactory keyFactory = KeyFactory.getInstance("RSA");
			return (RSAPrivateKey) keyFactory.generatePrivate(keySpec);
		} catch (NoSuchAlgorithmException e) {
			throw new Exception("无此算法");
		} catch (InvalidKeySpecException e) {
			throw new Exception("私钥非法");
		} catch (NullPointerException e) {
			throw new Exception("私钥数据为空");
		}
	}

	/**
	 * 公钥加密过程
	 *
	 * @param publicKey
	 *            公钥
	 * @param plainTextData
	 *            明文数据
	 * @return
	 * @throws Exception
	 *             加密过程中的异常信息
	 */
	public static String encrypt(RSAPublicKey publicKey, String plainTextData, String encode) throws Exception {
		if (publicKey == null) {
			throw new Exception("加密公钥为空, 请设置");
		}
		Cipher cipher = null;
		try {
			// 使用默认RSA
			cipher = Cipher.getInstance("RSA");
			// cipher= Cipher.getInstance("RSA", new BouncyCastleProvider());
			cipher.init(Cipher.ENCRYPT_MODE, publicKey);
			byte[] output = cipher.doFinal(plainTextData.getBytes(encode));
			return Base64.encode(output);
		} catch (NoSuchAlgorithmException e) {
			throw new Exception("无此加密算法");
		} catch (NoSuchPaddingException e) {
			e.printStackTrace();
			return null;
		} catch (InvalidKeyException e) {
			throw new Exception("加密公钥非法,请检查");
		} catch (IllegalBlockSizeException e) {
			throw new Exception("明文长度非法");
		} catch (BadPaddingException e) {
			throw new Exception("明文数据已损坏");
		}
	}

	/**
	 * 私钥加密过程
	 *
	 * @param key
	 *            私钥
	 * @param plainTextData
	 *            明文数据
	 * @return
	 * @throws Exception
	 *             加密过程中的异常信息
	 */
	public static byte[] encrypt(Key key, byte[] plainTextData) throws Exception {
		if (key == null) {
			throw new Exception("加密私钥为空, 请设置");
		}
		Cipher cipher = null;
		try {
			// 使用默认RSA
			cipher = Cipher.getInstance("RSA");
			cipher.init(Cipher.ENCRYPT_MODE, key);
			byte[] output = cipher.doFinal(plainTextData);
			return output;
		} catch (NoSuchAlgorithmException e) {
			throw new Exception("无此加密算法");
		} catch (NoSuchPaddingException e) {
			e.printStackTrace();
			return null;
		} catch (InvalidKeyException e) {
			throw new Exception("加密私钥非法,请检查");
		} catch (IllegalBlockSizeException e) {
			throw new Exception("明文长度非法");
		} catch (BadPaddingException e) {
			throw new Exception("明文数据已损坏");
		}
	}

	/**
	 * 私钥解密过程
	 *
	 * @param key
	 *            私钥
	 * @param cipherData
	 *            密文数据
	 * @return 明文
	 * @throws Exception
	 *             解密过程中的异常信息
	 */
	public static String decrypt(Key key, String cipherData, String encode) throws Exception {
		// 64位解码加密后的字符串
		byte[] inputByte = Base64.decode(cipherData);
		if (key == null) {
			throw new Exception("解密私钥为空, 请设置");
		}
		Cipher cipher = null;
		try {
			// 使用默认RSA
			cipher = Cipher.getInstance("RSA");
			// cipher= Cipher.getInstance("RSA", new BouncyCastleProvider());
			cipher.init(Cipher.DECRYPT_MODE, key);
			byte[] output = cipher.doFinal(inputByte);
			return new String(output, encode);
		} catch (NoSuchAlgorithmException e) {
			throw new Exception("无此解密算法");
		} catch (NoSuchPaddingException e) {
			e.printStackTrace();
			return null;
		} catch (InvalidKeyException e) {
			throw new Exception("解密私钥非法,请检查");
		} catch (IllegalBlockSizeException e) {
			throw new Exception("密文长度非法");
		} catch (BadPaddingException e) {
			throw new Exception("密文数据已损坏");
		}
	}

	/**
	 * 公钥解密过程
	 *
	 * @param publicKey
	 *            公钥
	 * @param cipherData
	 *            密文数据
	 * @return 明文
	 * @throws Exception
	 *             解密过程中的异常信息
	 */
	public static byte[] decrypt(RSAPublicKey publicKey, byte[] cipherData) throws Exception {
		if (publicKey == null) {
			throw new Exception("解密公钥为空, 请设置");
		}
		Cipher cipher = null;
		try {
			// 使用默认RSA
			cipher = Cipher.getInstance("RSA");
			// cipher= Cipher.getInstance("RSA", new BouncyCastleProvider());
			cipher.init(Cipher.DECRYPT_MODE, publicKey);
			byte[] output = cipher.doFinal(cipherData);
			return output;
		} catch (NoSuchAlgorithmException e) {
			throw new Exception("无此解密算法");
		} catch (NoSuchPaddingException e) {
			e.printStackTrace();
			return null;
		} catch (InvalidKeyException e) {
			throw new Exception("解密公钥非法,请检查");
		} catch (IllegalBlockSizeException e) {
			throw new Exception("密文长度非法");
		} catch (BadPaddingException e) {
			throw new Exception("密文数据已损坏");
		}
	}

	/**
	 * 字节数据转十六进制字符串
	 *
	 * @param data
	 *            输入数据
	 * @return 十六进制内容
	 */
	public static String byteArrayToString(byte[] data) {
		StringBuilder stringBuilder = new StringBuilder();
		for (int i = 0; i < data.length; i++) {
			// 取出字节的高四位 作为索引得到相应的十六进制标识符 注意无符号右移
			stringBuilder.append(HEX_CHAR[(data[i] & 0xf0) >>> 4]);
			// 取出字节的低四位 作为索引得到相应的十六进制标识符
			stringBuilder.append(HEX_CHAR[(data[i] & 0x0f)]);
			if (i < data.length - 1) {
				stringBuilder.append(' ');
			}
		}
		return stringBuilder.toString();
	}

	/**
	 * 把数组所有元素排序，并按照“参数=参数值”的模式用“&”字符拼接成字符串
	 * 
	 * @param params
	 *            需要排序并参与字符拼接的参数组
	 * @return 拼接后字符串
	 * @throws Exception
	 */
	public static String createLinkStringFrom(Map<String, String[]> params) throws Exception {

		TreeMap<String, String> paramsMap = new TreeMap<>();
		for (String name : params.keySet()) {
			String[] value = params.get(name);
			for (int i = 0; i < value.length; i++) {
				paramsMap.put(name, value[i]);
			}
		}

		StringBuffer sb = new StringBuffer();
		for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
			// if (entry.getValue() == null) {
			// throw new IllegalArgumentException("待签名值不能为空");
			// }
			if (!"sign".equals(entry.getKey())) {
				sb.append(entry.getKey()).append("=");
				if (entry.getValue() != null) {
					sb.append(URLDecoder.decode(entry.getValue().toString(), "utf-8"));
					// sb.append(entry.getValue().toString());
				}
				sb.append("&");
			}
		}
		sb.deleteCharAt(sb.length() - 1);
		return sb.toString();
	}

	/**
	 * 把数组所有元素排序，并按照“参数=参数值”的模式用“&”字符拼接成字符串
	 * 
	 * @param params
	 *            需要排序并参与字符拼接的参数组
	 * @return 拼接后字符串
	 * @throws Exception
	 */
	public static String createLinkStringFrom(TreeMap<String, String> params) throws Exception {

		StringBuffer sb = new StringBuffer();
		for (Map.Entry<String, String> entry : params.entrySet()) {
			// if (entry.getValue() == null) {
			// throw new IllegalArgumentException("待签名值不能为空");
			// }
			if (!"sign".equals(entry.getKey())) {
				sb.append(entry.getKey()).append("=");
				if (entry.getValue() != null) {
					sb.append(URLDecoder.decode(entry.getValue().toString(), "utf-8"));
					// sb.append(entry.getValue().toString());
				}
				sb.append("&");
			}
		}
		sb.deleteCharAt(sb.length() - 1);
		return sb.toString();
	}

	/**
	 * 把数组所有元素排序，并按照“参数=参数值”的模式用“&”字符拼接成字符串
	 * 
	 * @param params
	 *            需要排序并参与字符拼接的参数组
	 * @return 拼接后字符串
	 * @throws Exception
	 */
	public static String createLinkString(TreeMap<String, String> params) throws Exception {
		StringBuffer sb = new StringBuffer();
		for (Map.Entry<String, String> entry : params.entrySet()) {
			if (!StringUtils.isEmpty(entry.getValue()) && !"sign".equals(entry.getKey())) {
				sb.append(entry.getKey()).append("=").append(entry.getValue().toString()).append("&");
			}
		}
		sb.deleteCharAt(sb.length() - 1);
		return sb.toString();
	}

	/**
	 * 把数组所有元素排序，并按照“参数=参数值”的模式用“&”字符拼接成字符串
	 * 
	 * @param params
	 *            需要排序并参与字符拼接的参数组
	 * @return 拼接后字符串
	 * @throws Exception
	 */
	public static String createLinkStringTo(TreeMap<String, String> params) throws Exception {
		StringBuffer sb = new StringBuffer();
		for (Map.Entry<String, String> entry : params.entrySet()) {
			// if (entry.getValue() == null) {
			// throw new IllegalArgumentException("待签名值不能为空");
			// }
			sb.append(entry.getKey()).append("=");
			if (entry.getValue() != null) {
				sb.append(URLEncoder.encode(entry.getValue().toString(), "utf-8"));
				// sb.append(entry.getValue().toString());
			}
			sb.append("&");
		}
		sb.deleteCharAt(sb.length() - 1);
		return sb.toString();
	}

	private static String privateKeyByStr = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBANOeoQzM5FBjNmvA" +
			"XoOkWCFL8RGygFmCM5Qypaq8HTWNiOAS8e8zTzre7SDvSOOukpMnOhFIGj8H3v0l" +
			"HUMxsY49qCy8L2NaE7zTIoYkfKfQVQXANWEiq4QgKo++mvKxFkbEDxGQKlT825Pr" +
			"qCew0WhqhRxj6DkB+T/1PBLbBSRpAgMBAAECgYAzbNsKN0hMWK/C446UQv2/qaq9" +
			"eDlEhyVtoBkuMmSOvQREH5Z3YGqijcXmOP/nhGbOJ7wusuzd4FXKApjn2U2iJ9vQ" +
			"gF7eGVjZTG47xpmrRMQ6LSemrYcux42P2OsYMXs4QdUqbfbgkUfEbE7c1PQc/uy+" +
			"nkpWfQ7hMCjDsy4guQJBAPrxoaePuMNGY3aYjMqUGVeoCPITj5N2NINl6nOlrpoU" +
			"R9/EdVzi+m0g6RySJx7AbmA8jja1U27RwchJn5cxZz8CQQDX4inLsD9ep8HChams" +
			"YPSZzAcqwVfTVWPzXwiHMIfA7EystzRHD7Ihxnh2fuKULEWSqY4o8Jf6Q+iJ9Dh/" +
			"f3JXAkEA8KTM78G8Xc7fTPiHczDIiK3EPliRw8iEHUmbpmFI6crvDd/46CVmH0aD" +
			"JXnmd+/zKOiJPF9wbgJKgYZQu42NwwJBALjDrfXQgEvo0+JCN3d6+51ti2zCUQJk" +
			"gMjYOxpJJMau9uiTW8C95D0X+h2gdxdN1LWzPCI52DivSiRXyssELr0CQQDreEgp" +
			"e4h4T3GCq/yAHbQJCdjMTPE2yxw12zKHnxdkJJMR/zo421IE26GkGcB8zN0PvPtT" +
			"lQy79eO9fLkC/L7m";

	// 生成RSA 公私钥
	public static void main(String args[]) {
		try {
			String mobile = "15858236349";
			RSAPublicKey loadPublicKeyByStr = RSAEncrypt.loadPublicKeyByStr(
					"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCXgL8fT2FSG3bBUBpS0cP5nWtCDs5n+66MF3y74d9ARFIhvbpFm8CJiZ5aHmSWzNfuIAPU8k7MQuVF5NW26iHW9r2/xLpLIf28YzSyw3nnA+iPXjuuU0Dbcbt1n+1/caxggUiwMn/ObMR4z6kcV+pL+uZEa8bOtnHnQl76Rc1W5QIDAQAB");
			String encrypt = RSAEncrypt.encrypt(loadPublicKeyByStr, mobile, "UTF-8");
			System.out.println(encrypt);


			RSAPrivateKey loadPrivateKeyByStr;
			loadPrivateKeyByStr = RSAEncrypt.loadPrivateKeyByStr(
					"MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJeAvx9PYVIbdsFQGlLRw/mda0IOzmf7rowXfLvh30BEUiG9ukWbwImJnloeZJbM1+4gA9TyTsxC5UXk1bbqIdb2vb/Euksh/bxjNLLDeecD6I9eO65TQNtxu3Wf7X9xrGCBSLAyf85sxHjPqRxX6kv65kRrxs62cedCXvpFzVblAgMBAAECgYBd+KOTfh81WIeefFr3h9jw2S2QObLZWIj5qA/cUcuyBy6ScyY4ytTv+oZYC4YE62X786usx+cMV2nyom/VFwCJaWk5EiPEC5xcJLsvaCXEDJK5WbwuHduZ88vCIIEnH+YKzv+0BMU/fIc/uqICpqELY2u9e667RE3ImBTxulDoAQJBAN0tpsHVv+AukctqovCDVqUqkKyk0QZT+IO8w2zxa7T9y6/P4gEF87vQknlMebHQKnaengAcrv2USjEHUJvn8eUCQQCvWueUIwP/8ht7+G/a5AwuFODAcTFZTu39/ieskmeXEKGor1yrKf+PJGpTE3x354KcdK9uCzCrPlcJ4FX47YEBAkEAy3CnNxmeEN2k+v8N+r5D305EnphHL1PjfYEOHFH/qQ3c4c0L67cG1pVldS8TrKt1s3/4gs/fYZ2ZlHlO+uigxQJAYrU+JIItbza+x+MKO+IhBROVjF5rVAV9LHuTo63qB/xBs6268VK727y46TjP2MMGH8IDOmOsKsj1v8Z7PpubAQJAMCc8oNDTgfjrzsWsqJxmUjzlA6ZMLoOBsYLiHlY6UnHx+t5nNh3YhImhNgtpOsVaibG1jnXfMCgGk4ET0mhIVg==");
			mobile = RSAEncrypt.decrypt(loadPrivateKeyByStr,
					URLDecoder.decode(
							"WagxPdsbfPC1SKLIAjnO55pJlWzZhml66uThTqUfx9Y%2F8sNWbGM3aHatKmxnTrcidBITX0MIWUl%2F5HMOrDRGq5tnhKn5le90YPr%2BBKwUPM3DI3jVnVwEYhVBvHZvNAU%2FU7xPH4ZQRe%2FCwRznq14l5bDARsspvRS0l%2FekAjtVY8o%3D",
							"UTF-8"),
					"UTF-8");
			System.out.println(mobile);

			String sign = "fvrnFUOwQK%2FMc8F0Aep4rmVDClkd%2BFGTJpZBt3rLM9xBiZGHi8yU7P44I0ACooGASjpnHb3ipLhMaf9xaPgrRJ6%2Bfm%2Fz84mtbDaCfExL%2BIWfGHjVwVEs3TDUBeWiZ40iQRBxW5D5Xu1BvARqSIPmsu4%2FwS05lw%2BB4E4RBEzDxN4%3D";
			sign = URLDecoder.decode(sign, "UTF-8");
			TreeMap<String, String> paramMap = new TreeMap<>();
			paramMap.put("mobile_tel",
					URLDecoder.decode(
							"VM2Fp6IgKTg%2F3LliE0exO8X7OPEptdfJT2h%2BJrlgCY8zjvo3HBsiY68effQo7bb7jDTLBK75vJKVTufJPfDSDUBMwe%2Brj%2FQ7qpF%2FVrDOapshQlfalisFcwyRnYgvCERB0wvfbelV7cC5HG8jqdtz4EwYQBYTEbYotdm8ndAZUCE%3D",
							"UTF-8"));
			paramMap.put("timestamp", "1559636223216");
			paramMap.put("partner_id", "20190604");
			String createLinkString = createLinkString(paramMap);

			String sign2 = RSASignature.sign(createLinkString, loadPrivateKeyByStr, "UTF-8");
			boolean doCheck = RSASignature.doCheck(createLinkString(paramMap), sign, loadPublicKeyByStr);
			System.out.println(doCheck);

			// String mobile_tel = "15858236349";
			// mobile_tel = RSAEncrypt.encrypt(loadPublicKeyByStr, mobile_tel,
			// "UTF-8");
			// TreeMap<String, String> paramMap = new TreeMap<>();
			// paramMap.put("mobile_tel", mobile_tel);
			// paramMap.put("timestamp", String.valueOf(new Date().getTime()));
			// paramMap.put("partner_id", String.valueOf(20190604));
			// String urlParams = RSAEncrypt.createLinkString(paramMap);
			// String sign = RSASignature.sign(urlParams, loadPrivateKeyByStr,
			// "UTF-8");
			// paramMap.put("sign", sign);
			// String urlParams1 = RSAEncrypt.createLinkStringTo(paramMap);
			// System.out.println(urlParams1);
			// boolean doCheck =
			// RSASignature.doCheck(URLDecoder.decode("mobile_tel=dJlCsiV6f5gcU0TphSDmvKa0gOuLI%2BkldWoJttXlaSZrYsHc4NbBXFhp%2F%2FHG%2FYlKI32n8%2B%2F%2Bvqr0b%2FqGn3z%2FDLIW3X1DZiGS7wsp7MIEw6cTgivKq76e6t2rhGNbJ1f%2F95ri3J4xl3GNc7ozHg1hdj9R3SOeJsIJCUV2SVTeE2I%3D&partner_id=20190604&timestamp=1559641687443","utf-8"),
			// URLDecoder.decode("NYgzpXTw%2B9cKJlooKFAhls13i0v%2BedMbjuk1kapUrea2yQQfhNWDdS6BqsbHeaBz5abrMIe%2BxgTfOCxXFCk2cptpa6tyu%2FSP%2FWhmG%2F%2Batv15rmEp78RZ13zF39AGXRuLbCRVwpQFCgrvuBRV61gm3JDgW1i6assbtiKQb99acZM%3D","utf-8"),
			// loadPublicKeyByStr);
			//System.out.println(doCheck);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// genKeyPair("C:/Users/lingy/IdeaProjects/rsa-test/src/main/resources/rsakey/servkey/");
		// genKeyPair("C:/Users/lingy/IdeaProjects/rsa-test/src/main/resources/rsakey/clientkey/");

	}


}
